#!/usr/bin/envpython
# -*-coding:UTF-8-*-
'''
@File    :   tree_list.py
@Contact :   308711822@qq.com
@License :   (C) Copyright 2021-2225, Personal exclusive right.

@Modify Time      @Author    @Version    @Desciption
------------      -------    --------    -----------
2023/5/30 11:45   小钟同学      1.0         None
'''
from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends, Path, Body

from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.department.services import DepartmentBusinesses
from infirmary_admin_src.infirmary_smart_admin.infirmary_utils.convert2_help import convert_dict_to_camel_case
from infirmary_admin_src.infirmary_smart_admin.infirmary_utils.department_help import tree_convert_data



class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''
    pass


class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 schema_param: XParam=Depends(),
                 ):
        super().__init__(request=request)
        # 入参参数
        # 入参参数
        self.schema_param = schema_param


@RestControllerWithDepends()
class SystemDepartmentTreeListyController(IController):

    def business_login(self):
        pass
        # 查询用户信息，联表查询比较麻烦
        lists = DepartmentBusinesses.get_sys_dpartment_info()
        # 查询所有角色信息，进行匹配管理显示


        listdata = [convert_dict_to_camel_case(v, keepkey=['departmentId', 'managerId', 'parentId', 'sort'])for v in lists]
        return tree_convert_data(listdata)
